package com.pms.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pms.common.annotation.Log;
import com.pms.common.core.controller.BaseController;
import com.pms.common.core.domain.AjaxResult;
import com.pms.common.enums.BusinessType;
import com.pms.system.domain.PmsClientType;
import com.pms.system.service.IPmsClientTypeService;
import com.pms.common.utils.poi.ExcelUtil;
import com.pms.common.core.page.TableDataInfo;

/**
 * 客户类型Controller
 * 
 * @author 达瓦里氏
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/PmsClientType")
public class PmsClientTypeController extends BaseController
{
    @Autowired
    private IPmsClientTypeService pmsClientTypeService;

    /**
     * 查询客户类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmsClientType pmsClientType)
    {
        startPage();
        List<PmsClientType> list = pmsClientTypeService.selectPmsClientTypeList(pmsClientType);
        return getDataTable(list);
    }

    /**
     * 导出客户类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:export')")
//    @Log(title = "客户类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmsClientType pmsClientType)
    {
        List<PmsClientType> list = pmsClientTypeService.selectPmsClientTypeList(pmsClientType);
        ExcelUtil<PmsClientType> util = new ExcelUtil<PmsClientType>(PmsClientType.class);
        util.exportExcel(response, list, "客户类型数据");
    }

    /**
     * 获取客户类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmsClientTypeService.selectPmsClientTypeById(id));
    }

    /**
     * 新增客户类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:add')")
//    @Log(title = "客户类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsClientType pmsClientType)
    {
        return toAjax(pmsClientTypeService.insertPmsClientType(pmsClientType));
    }

    /**
     * 修改客户类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:edit')")
//    @Log(title = "客户类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsClientType pmsClientType)
    {
        return toAjax(pmsClientTypeService.updatePmsClientType(pmsClientType));
    }

    /**
     * 删除客户类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsClientType:remove')")
//    @Log(title = "客户类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsClientTypeService.deletePmsClientTypeByIds(ids));
    }
}
